#! /usr/bin/sh

# 将文件按照规定路径移动
declare -A arr

while read line
do
	key=`echo $line | awk '{split($0,t_arr,"/");print(t_arr[length(t_arr)])}'`
	value=`echo $line | awk '{match($0,/(^.*\/)/,arr);print(arr[1])}'`
	arr[$key]=$value
done < path.txt


#for k in ${!arr[@]}
#do
#	echo "$k-->${arr[$k]}"
#done

for pic in `ls pics`
do
	desc=${arr[$pic]}
	if [ ! -d $desc ];then
		mkdir -p $desc
	fi
	if [[ $desc == "" ]];then
		echo "-->$pic-->not in path.txt"
		continue
	fi
	cp pics/$pic $desc
done
